<template>
  <div>
    <hy-order-descriptions :orderId='orderId' v-if='loaded'></hy-order-descriptions>
    <a-divider orientation='left'>发货信息</a-divider>
    <f-table ref='orderDrugs' rowKey='orderDetailsId' :scroll='{x:true}' :showTotal='true' handler='hyBackOrderDetailsHandler' :tableColumns='orderDetailsColumns' :operator='operator' :params='queryParam' :api='api.hyOrderDetails' :pageSize='80' :autoLoad='false' :showPagination='false' :multiple='false'>
       <span slot='drugType' slot-scope='text, record, index'>
           <a-tag color='#2db7f5' v-if='text=="ZY"'>自营</a-tag>
           <a-tag color='#FF0000' v-if='text=="ZS"'>招商</a-tag>
       </span>
    </f-table>
  </div>

</template>

<script>
import api from "../../js/api"
import HyOrderDescriptions from "@/views/module/haiying/order/details/hyorder_descriptions"


export default {
  name: "HyOrderDetails",
  components: { HyOrderDescriptions },
  data() {
    let me = this
    //操作按钮
    let operator = []
    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: {},
      orderId: null,
      loaded: false,
      orderDetailsColumns: [],
      operator: operator
    }
  },
  created() {
  },
  computed: {},
  methods: {
    setData(data) {
      if (data && data.orderId) {
        this.orderId = data.orderId
        this.loaded = true
        this.queryParam.orderId = data.orderId
        this.orderDetailsColumns = this.getCol(data)
        this.$refs["orderDrugs"].refresh(false)
      }
    },
    getCol(data) {
      let saleManId = !data.saleManId
      let sendType = data.sendType
      let deptType = data.deptType
      let isZbj = false
      if (sendType == 3) {
        isZbj = true
      }
      return [
        {
          title: "商品名称",
          align: "left",
          ellipsis: true,
          width: "140px",
          dataIndex: "drugsName"
        },
        {
          title: "规格",
          align: "left",
          ellipsis: true,
          width: "120px",
          dataIndex: "drugsSpec"
        },
        {
          title: "批号",
          align: "left",
          width: "80px",
          dataIndex: "drugLotNo"
        },
        {
          title: "类型",
          align: "center",
          width: "80px",
          dataIndex: "drugType",
          scopedSlots: { customRender: "drugType" }
        },
        {
          title: "销售单价",
          align: "center",
          width: "80px",
          dataIndex: "salePrice"
        },
        {
          title: "数量",
          align: "center",
          width: "80px",
          dataIndex: "saleNum"
        },
        {
          title: "销售金额",
          align: "center",
          width: "80px",
          needTotal: true,
          dataIndex: "saleAmount"
        },
        {
          title: "底价",
          align: "center",
          width: "100px",
          needTotal: true,
          hidden: !isZbj,
          dataIndex: "customFloorAmount"
        },
        {
          title: "税金",
          align: "center",
          width: "100px",
          needTotal: true,
          hidden: !isZbj,
          dataIndex: "customGapUpAmount"
        },
        {
          title: "资保金应收",
          align: "center",
          width: "90px",
          hidden: !isZbj,
          dataIndex: "customBond"
        },
        {
          title: "部门",
          align: "center",
          hidden: deptType == "ZS",
          width: "90px",
          children: [
            {
              title: "结算价",
              align: "center",
              width: "90px",
              dataIndex: "deptPrice"
            },
            {
              title: "结算标准",
              align: "center",
              width: "90px",
              dataIndex: "deptRate"
            },
            {
              title: "结算金额",
              align: "center",
              width: "90px",
              dataIndex: "deptSettleAmount"
            }
          ]
        },
        {
          title: "渠道商",
          align: "center",
          width: "120px",
          hidden: deptType == "ZY",
          children: [
            {
              title: "结算价",
              align: "center",
              width: "120px",
              needTotal: true,
              hidden: saleManId,
              dataIndex: "settlePrice"
            },
            {
              title: "结算标准",
              align: "center",
              width: "120px",
              needTotal: true,
              hidden: saleManId,
              dataIndex: "settleRate"
            },
            {
              title: "结算金额",
              align: "center",
              width: "130px",
              needTotal: true,
              hidden: saleManId,
              dataIndex: "settleAmount"
            }
          ]
        }
      ]
    },
    handleSuccess() {
      this.$refs["orderDrugs"].refresh()
      this.$emit("success")
    }
  }
}
</script>